import os

def is_video_file(file_path):
    # 定义视频文件后缀名列表
    video_extensions = ['.mp4', '.avi', '.mkv', '.mov', '.flv', '.wmv']

    # 获取文件的扩展名
    file_extension = os.path.splitext(file_path)[-1].lower()

    # 判断扩展名是否在视频后缀名列表中
    return file_extension in video_extensions

def rename_videos_in_folder(folder_path, prefix=""):
    # 获取文件夹中的所有文件
    video_files = [f for f in os.listdir(folder_path) if is_video_file(os.path.join(folder_path, f))]
    print(video_files)
    # 遍历视频文件并重命名
    for i, video_file in enumerate(video_files):
        # 获取文件的扩展名
        file_extension = os.path.splitext(video_file)[-1].lower()

        # 新的文件名，添加了前缀
        new_file_name = f"{prefix}{i + 1}{file_extension}"
        print(new_file_name)
        # 构建新的文件路径
        new_file_path = os.path.join(folder_path, new_file_name)

        # 重命名文件
        os.rename(os.path.join(folder_path, video_file), new_file_path)

    print(f"文件夹 {folder_path} 中的视频文件已重命名完成")

# 调用函数并传入文件夹路径和前缀
video_folder = '/path/to/your/video/folder'
rename_videos_in_folder(video_folder, prefix="video_")
